package com.cspg.ssss.service;

import com.cspg.ssss.domain.ApproveGroupStat;
import com.cspg.ssss.domain.ApproveUserSelectEntity;
import com.cspg.ssss.repository.ApproveUserSelectEntityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//审核类型，0-打分审核，1-反馈审核，2-反馈终审，3-加分审核，4-加分终审,5-反馈局领导审核，6-加分局领导审核
@Service
public class ApproveUserSelectService {

    @Autowired
    ApproveUserSelectEntityMapper approveUserSelectEntityMapper;


    public int addApproveUserSelect(ApproveUserSelectEntity en){
        Map<String,Object> condition = new HashMap<String,Object>();
        condition.put("problem_id",en.getProblem_id());
        condition.put("user_id",en.getUser_id());
        condition.put("approve_type",en.getApprove_type());

        List<ApproveUserSelectEntity> retLs = approveUserSelectEntityMapper.selectApproveUserSelect(condition);
        if(retLs == null || retLs.size() == 0){
            approveUserSelectEntityMapper.insertApproveUserSelect(en);
        }

        return 0;

    }

    public void  deleteApproveUserSelect(Map<String,Object> condition){
        approveUserSelectEntityMapper.delApproveUserSelect(condition);
    }

    public List<ApproveUserSelectEntity> selectProblemApproveUsers(Map<String,Object> condition){
        return approveUserSelectEntityMapper.selectProblemApproveUsers(condition);
    }

    public List<ApproveUserSelectEntity> selectScoreApplyApproveUsers(Map<String,Object> condition){
        return approveUserSelectEntityMapper.selectScoreApplyApproveUsers(condition);
    }

    public List<ApproveGroupStat> selectProblemApproveUsersByGroupUser(Map<String,Object> condition)
    {
        return approveUserSelectEntityMapper.selectProblemApproveUsersByGroupUser(condition);
    }

    public List<ApproveGroupStat> selectScoreApplyApproveUsersByGroupUser(Map<String,Object> condition){
        return approveUserSelectEntityMapper.selectScoreApplyApproveUsersByGroupUser(condition);
    }

    public void batchInsertApproveUser(Map<String,Object> condition){
        approveUserSelectEntityMapper.batchInsertApproveUser(condition);
    }

    public void batchDeleteApproveUser(Map<String,Object> condition){
        approveUserSelectEntityMapper.batchDeleteApproveUser(condition);
    }

    public void batchInsertApproveUserForGrade(Map<String,Object> condition){
        approveUserSelectEntityMapper.batchInsertApproveUserForGrade(condition);
    }

    public void batchDeleteApproveUserForGrade(Map<String,Object> condition){
        approveUserSelectEntityMapper.batchDeleteApproveUserForGrade(condition);
    }
}
